package com.ruoyi.graduate.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.graduate.domain.param.MsCollectionAddParam;
import com.ruoyi.graduate.service.IMsCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 用户收藏控制接口
 */
@RestController
@RequestMapping("/api/collection")
@Api(tags = "用户收藏控制器")
public class MsCollectionController extends BaseController {

    @Autowired
    private IMsCollectionService msCollectionService;


    @ApiOperation("用户收藏")
    @PostMapping
    public AjaxResult add(@RequestBody MsCollectionAddParam param){

        return msCollectionService.addMsCollection(param);
    }


    @ApiOperation("用户删除收藏")
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Integer id){

        boolean b = msCollectionService.removeById(id);

        return b ? AjaxResult.success() : AjaxResult.error();
    }


    @ApiOperation("用户查询收藏套餐列表")
    @GetMapping("/{userId}")
    public AjaxResult getMsCollection(@PathVariable Long userId){

        return msCollectionService.getList(userId);
    }




}
